package com.scf.contract.controller;

import com.scf.contract.entity.Bank;
import com.scf.contract.service.BankService;
import com.scf.uitl.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-15-15:21
 */
@RestController
@RequestMapping("/bank")
public class BankController {
    @Resource
    BankService bankService;

    @GetMapping("/all")
    public ResponseResult selectAll(){
        List<Bank> banks = bankService.selectAll();
        ResponseResult responesResult = new ResponseResult();
        responesResult.setCode(200);
        responesResult.setData(banks);
        return responesResult;
    }

    @GetMapping("/getBankByBcid/{bcid}")
    public ResponseResult getBankByBcid(@PathVariable int bcid){
        Bank bankByBcid = bankService.getBankByBcid(bcid);
        ResponseResult responesResult = new ResponseResult();
        responesResult.setCode(200);
        responesResult.setData(bankByBcid);
        return responesResult;
    }

    @PostMapping("/addBank")
    public ResponseResult addBank(@RequestBody Bank bank){
        Bank b = new Bank();
        b.setBctype(bank.getBctype());
        b.setBcdeposit(bank.getBcdeposit());
        b.setBcBelonging(bank.getBcBelonging());
        b.setBcnumber(bank.getBcnumber());
        b.setBctitle(bank.getBctitle());
        ResponseResult responesResult = new ResponseResult();
        responesResult.setCode(200);
        responesResult.setData(null);
        return responesResult;
    }

}

